package com.utils;

import com.bean.anno.BaseConfig;
import com.mapper.repository.mysql.BaseConfigRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class BaseUtils {

    @Autowired
    private BaseConfigRepository baseConfigRepository;

    public String getBaseConfigByName(String name){
        BaseConfig baseConfig = this.baseConfigRepository.getByName(name);
        if(baseConfig!=null){
            return baseConfig.getParam();
        }else{
            return "";
        }
    }


    @Value("${wechat.server.ip}")
    private String server;

    @Value("${wechat.server.port}")
    private String port;

    @Value("${wechat.server.domain}")
    private String domain;

    public String getWechatUrl(){
        if(!domain.equals("")){
            return domain;
        }else{
            return "http://"+server+":"+port+"/";
        }
    }
}
